<?php
session_start();
require_once('db.php');
require_once('utils.php');

$id = $_POST['id'];
session_check();
if(empty($user)){
    return;
}


$q = sprintf("SELECT * FROM sweets,todo WHERE asigned='%s' and sweets.id = todo.sweetid and todo.sweetid='%s'",
mysql_real_escape_string($user), mysql_real_escape_string($id));
$res = mysql_query($q);
if(mysql_num_rows($res) != 1){
    print $q;
	return;
    }

$q = sprintf("update todo set doit=true where sweetid='%s'",
mysql_real_escape_string($id));
$res = mysql_query($q);
$res ? print $id : print '';

?>
